<?php 
/**
 * Template Name: Contact
 * @package Halong Junk Cruise
 * @subpackage Signature
 * @since 07/2013
 */	
get_header(); ?>
<div id="container">	
    <div class="wrapper">
    	<div class="grid24" style="margin-top:20px;">
        	<div class="crumbs">
                <?php qt_custom_breadcrumbs(0, 1); ?>
            </div><!-- crumbs --> 
            <section class="content">
                <h1 class="title1">Contact us</h1>
                <div class="contact">
                    <div class="google-map">
                        <iframe width="530" scrolling="no" height="300" frameborder="0" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=Brooklyn,+NY,+USA&amp;aq=0&amp;sll=37.0625,-95.677068&amp;sspn=47.704107,79.013672&amp;ie=UTF8&amp;hq=&amp;hnear=Brooklyn,+Kings,+New+York&amp;ll=40.649974,-73.949919&amp;spn=0.01628,0.028238&amp;z=14&amp;iwloc=A&amp;output=embed">
                        </iframe>
                    </div>
                </div><!-- contact -->               
    		</section>
 			<aside class="grid4">
            <?php
				$country	= get_countries(get_bloginfo('template_url').'/data/countries.xml');
				//$gender_arr = array('Mr', 'Ms', 'Mrs'); 
				$url= get_permalink();
				$isSentMail = 0;
				if( isset($_POST['btnSubmit']) ) {
					remove_wp_magic_quotes();
					
					$data = array(
						'subject'		=> 'Contact of '. trim($_POST['yname']),
						'msg_title'		=> 'Contact from VietnamHalongCruises.com',
						//'to_email'		=> get_option('admin_email'),
						'to_email'		=> 'lehoang.tnk@gmail.com',
						//'cc'			=> 'lehoang.tnk@gmail.com', 
						//'bcc'			=> get_option('admin_email'),
						//'sex'			=> $gender_arr[$_POST['sex']],
						'from_name'		=> trim($_POST['yname']), 
						'from_email'	=> trim($_POST['yemail']),
						'yphone'		=> trim($_POST['yphone']),
						'national'		=> trim($_POST['national']),
						'message'		=> trim($_POST['message'])
					);
				
					if( wp_contact_us($data) ) {
						$isSentMail = 1;
					}
				} 
				if( $isSentMail ) {
				?>	<br />
                    <div class="contact-mail-sent-ok" style="display: block;">
                    	<p>Your message has been sent.<br />As soon as we receive your request, we will confirm immediately.<br />Thank you!</p>
						<p><a href="<?php echo HOME_URL; ?>" style="text-decoration:underline">Click here</a> to return home page</p>
                    </div>
                <?php
				} //end ifbtnSubmit 
				else {
				?>
                <div class="contact_form">
                     <form class="frm_contact" method="post" action="<?php echo $url; ?>">
                    
                        <div>
                           <input name="yname" type="text" placeholder="Name:" value="<?php echo $data['from_name']; ?>">           
                        </div>    
                        
                        <div>
                           <input name="yemail" type="text" placeholder="Email:" value="<?php echo $data['from_email']; ?>">           
                        </div>
                            
                        <div>
                           <input name="yphone" type="text" placeholder="Phone:" value="<?php echo $data['yphone']; ?>">           
                        </div>
                        
                        <div>
                            <SELECT name="national" required>
                            <OPTION selected value="">Select nationality</option>
                            <?php foreach ($country as $key => $value) : ?>
                                <option value="<?php echo $key; ?>" <?php if( $data['national'] == $key ) echo 'selected="selected"' ?>><?php echo $key; ?></option>
                            <?php endforeach; ?>
                    		</SELECT>
                        </div>      
                        
                        <div>
                             <textarea name="message" cols="1" rows="10" placeholder="Message:" required="<?php echo $data['message']; ?>"></textarea>  
                        </div>  
                        
                        <div style="margin-top:20px;">
                            <input type="reset" value="clear">
                            <input type="submit" name="btnSubmit" class="" value="send">
                        </div>     
                    
                    </form>
                </div>
				<?php 
                }
                ?> 
            </aside>  
      	</div><!-- grid 24 -->
    </div><!-- wrapper -->
</div> <!-- container -->
<?php get_footer(); ?>
